﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.zynga.skelly.animation {
    import de.polygonal.ds.*;

	/**
	 * 维护IAnimated的列表, 以及对前后AnimationList的引用 
	 */
    public class AnimationList {

        public var fps:int;
        var m_uIndex:uint;
        var m_timeMs:int;
        var m_timeAccumulated:int;
        var m_lastProcessTimeMs:int;
        var m_animations:SLinkedList;
        public var prevList:AnimationList;
        public var nextList:AnimationList;

        public function AnimationList(_arg1:int, _arg2:int, _arg3:uint){
            this.m_animations = new SLinkedList();
            super();
            this.fps = _arg1;
            this.m_timeMs = _arg2;
            this.m_uIndex = _arg3;
        }
        public function process(_arg1:int):void{
            var _local3:uint;
            var _local4:SListIterator;
            var _local5:IAnimated;
            if (!this.m_animations.head){
                return;
            };
            var _local2:int = (_arg1 - this.m_lastProcessTimeMs);
            this.m_lastProcessTimeMs = _arg1;
            this.m_timeAccumulated = (this.m_timeAccumulated + _local2);
            if (this.m_timeAccumulated >= (this.m_timeMs - 20)){
                if ((((this.m_timeAccumulated <= (this.m_timeMs + 20))) || ((_local2 <= (this.m_timeMs + 5))))){
                    _local3 = 1;
                    this.m_timeAccumulated = 0;
                } else {
                    _local3 = (this.m_timeAccumulated / this.m_timeMs);
                    this.m_timeAccumulated = (this.m_timeAccumulated - (_local3 * this.m_timeMs));
                };
                _local4 = this.m_animations.getListIterator();
                _local4.start();
                while (_local4.data != null) {
                    _local5 = _local4.data;
                    if (_local5.animate(_local3)){
                        _local4.forth();
                    } else {
                        _local4.remove();
                    };
                };
            };
        }
        public function add(_arg1:IAnimated):void{
            this.m_animations.append(_arg1);
        }
        public function contains(_arg1:IAnimated):Boolean{
            var _local2:SListIterator = this.m_animations.nodeOf(_arg1);
            if (_local2){
                return (true);
            };
            return (false);
        }
        public function remove(_arg1:IAnimated):void{
            var _local2:SListIterator = this.m_animations.nodeOf(_arg1);
            if (_local2){
                _local2.remove();
            } else {
                throw (new Error("AnimationList remove called with unfound anim:", _arg1));
            };
        }

    }
}//package com.zynga.skelly.animation 
